<template>
  <Card style="margin-bottom:25px;">
    <p slot="title">
      <Icon type="md-person-add"></Icon>
      个人中心
    </p>
    <person-frm ref="personFrm" @on-success-valid="handleSubmit"></person-frm>
  </Card>
</template>

<script>
import personFrm from './person/index.vue'
import { editPerson } from '@/api/manage'

export default {
  components: {
    personFrm
  },
  methods: {
    handleSubmit ({ manage_name, manage_phone, manage_pass, team_name, avator }) {
      editPerson({ manage_name, manage_phone, manage_pass, team_name, avator }).then(res => {
        const data = res.data
        console.log(data)
        if (data.code === 200) {
          this.$refs.personFrm.success()
          this.$Message.success(data.message)
        } else {
          this.$refs.personFrm.fail()
          this.$Message.error(data.error)
        }
      }).catch(() => {
        this.$refs.personFrm.fail()
        this.$Message.error('保存失败')
      })
    }
  }
}
</script>
